import VueRouter from 'vue-router';
import Vue from 'vue';
import Nofound from "@/pages/Nofound.vue";
import Home from "@/pages/Home.vue";
import GoodsList from "@/pages/GoodsList.vue";
import My from "@/pages/My.vue";
import NewsList from "@/pages/NewsList.vue";
import One from "@/pages/One.vue";
import Two from "@/pages/Two.vue";
import Three from "@/pages/Three.vue";
import Cart from "../../../Lesson12/code/10- 子路由/src/pages/Cart.vue";
import Collect from "../../../Lesson12/code/10- 子路由/src/pages/Collect.vue";

Vue.use(VueRouter);
const router =new VueRouter({
    routes:[
        {
            path:'*',
            component:Nofound
        },
        {
            path:'/',
            component:Home
        }, {
            path:"/home",
            redirect:"/"
        },{
            path:'/goodsList',
            name:'goods',
            component:GoodsList
        },{
            path:"/my",
            component:My,
            //子路由
            children:[
                {
                    path:"/my",
                    redirect:"/my/cart"
                },
                {
                    path:"cart",
                    name:'one',
                    component:Cart
                },
                {
                   path:"collect",
                    name:"two",
                    component:Collect
                }
            ]
        },{
            path:"/newsList",
            alias:["/one","/two","/three"], //任意地址都可以访问该组件
            component:NewsList
        },{
            path:"/more",
            components:{
                One,
                Two,
                Three
            }
        }
    ],
    mode:"history",
    linkExactActiveClass:"active"
});
export default router;